//
//  DFStrikethroughLabel.m
//  超级团购
//
//  Created by HZ on 14-10-5.
//  Copyright (c) 2014年 cn.df. All rights reserved.
//

#import "DFStrikethroughLabel.h"

@implementation DFStrikethroughLabel



- (void)drawRect:(CGRect)rect
{
    if (_isStrikethrough)
    {
        CGSize contentSize = [self.text sizeWithFont:self.font constrainedToSize:self.frame.size];
        CGContextRef context = UIGraphicsGetCurrentContext();

        // CGFloat color[4] = {0.667, 0.667, 0.667, 1.0};
        //CGContextSetStrokeColor(context, color);
        if(!_strikethroughColor) {
            _strikethroughColor = [UIColor blackColor];
        }
        [_strikethroughColor setStroke];
        CGContextSetLineWidth(context, _strikethroughWidth<=0?1:_strikethroughWidth);
        CGContextBeginPath(context);
        CGFloat x = self.bounds.origin.x;
        CGFloat y = (self.bounds.size.height - self.bounds.origin.y) / 2.0;
        CGContextMoveToPoint(context, x, y);
        CGContextAddLineToPoint(context, x + contentSize.width, y);
        CGContextStrokePath(context);
        //CGContextRelease(context);
    }
    
    [super drawRect:rect];
    
}

@end
